<?php

namespace App\Http\Controllers\Logic;

use App\Http\Controllers\Controller;
use App\Model\OADept;
use App\Model\OARole;
use App\Model\User;
use Illuminate\Http\Request;

/**
 * Class UserLogic
 * @package App\Http\Controllers\Logic
 * @desc 用户相关逻辑
 */
class UserLogic extends Controller
{
    public function getUserInfo($uid){
        $user = User::query()->where('fhs_u_id',$uid)
                            ->first([
                                'fhs_u_id as uid',
                                'fhs_u_lgname as lgname',
                                'fhs_u_name as username',
                                'fhs_u_type as role',
                                'fhs_u_role as rolelist',
                                'fhs_u_bmen as deptlist'
                                ])
                            ->toArray();
        //查角色
       $user = $this->getUserRole($user);
        //查部门
        $this->getUserDept($user);
        dd($user);
    }

    //查用户角色
    private function getUserRole($user)
    {
        $user['rolelist'] = OARole::query()->whereIn('fhs_r_key',explode(',',$user['rolelist']))->pluck('fhs_r_name')->toArray();
        $user['role'] = OARole::query()->where('fhs_r_key',$user['role'])->value('fhs_r_name');
        return $user;
    }
    //查用户部门
    private function getUserDept($user)
    {
        $user['deptlist'] = OADept::query()->whereIn('');
    }

    //查用户列表
    public function getUserList($input)
    {

    }
}
